export default {
  props: ['prompt'],
  data() {
    return {
      title: "温馨提示",
      parClass: {},
    }
  },
  methods: {
    // 选择的分类
    changeClient(e) {
      console.log(e)
    },
    // 关闭弹窗
    closePopup() {
      this.prompt.state = false
      this.bgBody()
    },
    // 返回值
    conserveData() {
      this.$emit('getdata', this.parClass)
      this.prompt.state = false
      this.bgBody()
    },
    // 弹出中 背景不可滑动
    bgBody() {
      let vm = this
      if (vm.prompt.state) {
        document.getElementsByTagName("body")[0].style.overflow = "hidden"
      } else {
        document.getElementsByTagName("body")[0].style.overflow = "auto"
      }
    }
  },
  watch: {
    prompt(){
      let vm = this
      // vm.bgBody()
      // 是否有值
      if (Object.keys(vm.prompt).length) {
        // 是否为开启状态
        if(vm.prompt.state){
          // 默认标题
          if (vm.prompt.title !== '') {
            vm.title = vm.prompt.title
          }
          setTimeout(() => {
            let top = document.getElementById("Message").children[0]
            let style = top.clientHeight
            top.style.marginTop = "-" + style / 2 + 'px'
            // vm.styleType = "margin-top:-" + style / 2 + 'px'
          }, 5)
          console.log("vm.prompt",vm.prompt)
        }
      }
    }
  },
  created() {

  }
}